home *** CD-ROM | disk | FTP | other *** search
- #ifndef __GRAPHICS_H__
- #define __GRAPHICS_H__
-
- #include "QDOffscreen.h"
-
- #define MAX_TE_HANDLES 1
-
- typedef struct
- {
- WindowPtr theWindowPtr; /* window ptr of window */
- short windowIndex; /* index of window in program's window list */
- short windowWidth; /* width of window content, in pixels */
- short windowHeight; /* height of window content, in pixels */
- short windowType; /* type of window (see IM Essentials, 4-80) */
- short windowDepth; /* current pixel depth of window */
- short maxDepth; /* maximum pixel depth of window */
- Boolean hasCloseBox; /* window has a close box */
- Boolean offscreenNeedsUpdate; /* TRUE if offscreen bitmap needs redrawing */
- Boolean isColor; /* TRUE if color, FALSE if grayscale */
- Boolean topLeftInitted; /* TRUE if top/left coords initted */
- Point initialTopLeft; /* initial window bounds when opened */
- Rect windowBounds; /* on screen rectangle of window content */
- TEHandle hTE[MAX_TE_HANDLES]; /* array of textedit handles */
- Str31 windowTitle; /* pascal string, title of window */
- } WindowDataRec, *WindowDataPtr, **WindowDataHandle;
-
- typedef short (*dispatchProcPtr)(WindowDataHandle theData, short theMessage, unsigned long misc);
-
- typedef struct /* exactly the same as WindowDataRec */
- { /* + dispatchProc at end */
- WindowPtr theWindowPtr;
- short windowIndex;
- short windowWidth;
- short windowHeight;
- short windowType;
- short windowDepth;
- short maxDepth;
- Boolean hasCloseBox;
- Boolean offscreenNeedsUpdate;
- Boolean isColor;
- Boolean topLeftInitted;
- Point initialTopLeft;
- Rect windowBounds;
- TEHandle hTE[MAX_TE_HANDLES];
- Str31 windowTitle;
- dispatchProcPtr dispatchProc; /* called with message of windowish event */
- } ExtendedWindowDataRec, *ExtendedWindowDataPtr, **ExtendedWindowDataHandle;
-
- enum /* messages passed to window's dispatch procedure */
- {
- kNull=0, /* on null event when window is active, frgrnd/bkgrnd */
- kStartup, /* on program startup */
- kShutdown, /* on program shutdown */
- kInitialize, /* just before window is created & shown */
- kOpen, /* just after window is created & shown */
- kUpdate, /* during window update -- draw contents to current grafport */
- kClose, /* just before window is closed -- this can cancel close */
- kDispose, /* just after window is closed/disposed */
- kActivate, /* on window activate event */
- kDeactivate, /* on window deactivate event */
- kSuspend, /* on program suspension (switched into background) */
- kResume, /* on program resuming (switching into foreground) */
- kKeydown, /* on keydown event when window is active & in foreground */
- kMousedown, /* on mousedown event in window content when active & in frgrnd */
- kUndo, /* specific to window */
- kCut,
- kCopy,
- kPaste,
- kClear,
- kSelectAll,
- kChangeDepth, /* offscreen bitmap just created or pixel depth changed */
- kCopybits, /* actual copybits to update onscreen window from offscreen */
- kDrag,
- kGrow,
- kZoom,
- kGetGrowSize
- };
-
- enum /* return codes from window dispatch procedure */
- {
- kSuccess=0, /* message handled, no further processing please */
- kFailure, /* message not handled, use default action if any */
- kCancel /* message refused, cancel action (only good with kClose) */
- };
-
- #define GetWindowData_windowPtr(x) ((**(x)).theWindowPtr)
- #define GetWindowData_windowIndex(x) ((**(x)).windowIndex)
- #define GetWindowData_windowWidth(x) ((**(x)).windowWidth)
- #define GetWindowData_windowHeight(x) ((**(x)).windowHeight)
- #define GetWindowData_windowType(x) ((**(x)).windowType)
- #define GetWindowData_windowDepth(x) ((**(x)).windowDepth)
- #define GetWindowData_maxDepth(x) ((**(x)).maxDepth)
- #define GetWindowData_hasCloseBox(x) ((**(x)).hasCloseBox)
- #define GetWindowData_offscreenNeedsUpdate(x) ((**(x)).offscreenNeedsUpdate)
- #define GetWindowData_isColor(x) ((**(x)).isColor)
- #define GetWindowData_windowPos(x) ((**(x)).initialTopLeft)
- #define GetWindowData_windowPosInitted(x) ((**(x)).topLeftInitted)
- #define GetWindowData_windowBounds(x) ((**(x)).windowBounds)
- #define GetWindowData_windowBoundsTopLeft(x) (*((Point*)((**(x)).windowBounds)))
- #define GetWindowData_hTE(x, y) ((**(x)).hTE[y])
- #define GetWindowData_windowTitle(x) ((**(x)).windowTitle)
- #define GetWindowData_dispatchProc(x) ((**(x)).dispatchProc)
-
- #define SetWindowData_windowPtr(x, y) { (**(x)).theWindowPtr=y; }
- #define SetWindowData_windowIndex(x, y) { (**(x)).windowIndex=y; }
- #define SetWindowData_windowWidth(x, y) { (**(x)).windowWidth=y; }
- #define SetWindowData_windowHeight(x, y) { (**(x)).windowHeight=y; }
- #define SetWindowData_windowType(x, y) { (**(x)).windowType=y; }
- #define SetWindowData_windowDepth(x, y) { (**(x)).windowDepth=y; }
- #define SetWindowData_maxDepth(x, y) { (**(x)).maxDepth=y; }
- #define SetWindowData_hasCloseBox(x, y) { (**(x)).hasCloseBox=y; }
- #define SetWindowData_offscreenNeedsUpdate(x,y) { (**(x)).offscreenNeedsUpdate=y; }
- #define SetWindowData_isColor(x, y) { (**(x)).isColor=y; }
- #define SetWindowData_windowPos(x, y) { (**(x)).initialTopLeft=y; }
- #define SetWindowData_windowPosInitted(x, y) { (**(x)).topLeftInitted=y; }
- #define SetWindowData_windowBounds(x, y) { (**(x)).windowBounds=y; }
- #define SetWindowData_hTE(x, y, z) { (**(x)).hTE[y]=z; }
- #define SetWindowData_windowTitle(x, y) { Mymemcpy((Ptr)(**(x)).windowTitle, (Ptr)y, y[0]+1); }
- #define SetWindowData_dispatchProc(x, y) { (**(x)).dispatchProc=y; }
-
- #define GetWindowIndex(x) GetWindowData_windowIndex(x)
-
- #define GetWindowPtr(x) GetWindowData_windowPtr(x)
- #define GetIndWindowPtr(x) GetWindowData_windowPtr(GetWindowDataHandle(x))
-
- #define GetOffscreenPtr(x) \
- (gHasColorQD ? (WindowPtr)gTheGWorld[GetWindowData_windowIndex(x)] : \
- (WindowPtr)gBWGrafPtr[GetWindowData_windowIndex(x)])
- #define GetIndOffscreenPtr(x) \
- (gHasColorQD ? (WindowPtr)gTheGWorld[x] : (WindowPtr)gBWGrafPtr[x])
-
- #define GetIndWindowPos(x) \
- GetWindowData_windowPos(GetWindowDataHandle(x))
-
- #define GetIndWindowPosInitted(x) \
- GetWindowData_windowPosInitted(GetWindowDataHandle(x))
-
- #define SetIndWindowPos(x, y) \
- SetWindowData_windowPos(GetWindowDataHandle(x), y)
-
- #define SetIndWindowPosInitted(x, y) \
- SetWindowData_windowPosInitted(GetWindowDataHandle(x), y)
-
- #define SetIndWindowTitle(x, y) \
- SetWindowData_windowTitle(GetWindowDataHandle(x), y)
-
- #define WindowExistsQQ(x) (GetWindowPtr((x))!=0L)
- #define IndWindowExistsQQ(x) (GetIndWindowPtr((x))!=0L)
-
- #define ForceUpdateTheWindow(x) \
- { SetWindowData_offscreenNeedsUpdate(x, TRUE); \
- UpdateTheWindow((ExtendedWindowDataHandle)(x)); }
-
- #define ForceUpdateTheIndWindow(x) \
- ForceUpdateTheWindow(GetWindowDataHandle(x))
-
- #define CloseTheIndWindow(x) \
- CloseTheWindow(GetWindowDataHandle(x))
-
- #define GetWindowDepth(x) \
- GetIndWindowDepth(GetWindowData_windowIndex(x))
-
- #define CallIndDispatchProc(x, y, z) \
- CallDispatchProc(GetWindowDataHandle(x), (y), (z))
-
- #define SetIndDispatchProc(x, y) \
- SetWindowData_dispatchProc(GetWindowDataHandle(x), y)
-
- /***************************************************************************************/
-
- Boolean InitTheGraphics(void);
- void ShutDownTheGraphics(void);
- OSErr OpenTheIndWindow(short index);
- void GetMainScreenBounds(void);
- short GetIndWindowDepth(short index);
- short GetBiggestDeviceDepth(ExtendedWindowDataHandle theData);
- Boolean WindowIsColor(ExtendedWindowDataHandle theData);
- void UpdateTheWindow(ExtendedWindowDataHandle theData);
- Boolean CloseTheWindow(ExtendedWindowDataHandle theData);
- PicHandle DrawThePicture(PicHandle thePict, short whichPict, short x, short y);
- PicHandle ReleaseThePict(PicHandle thePict);
- short CallDispatchProc(ExtendedWindowDataHandle theData, short theMessage,
- unsigned long misc);
- void KillOffscreen(short index);
- ExtendedWindowDataHandle GetWindowDataHandle(short index);
- Point GetWindowBoundsTopLeft(WindowDataHandle theData);
- GrafPtr GetOffscreenPtrFunction(WindowDataHandle theData);
-
- #endif
-